(1) Field of the Invention
The invention relates to a picture coding device that codes moving picture data in compliance with the H.264/AVC standard.
(2) Description of the Related Art
Data compression techniques defined in the H.264/AVC standard include entropy coding (variable length coding). For entropy coding methods, there are two methods available, the Context-based Adaptive Variable Length Coding (CAVLC) and the Context-based Adaptive Binary Arithmetic Coding (CABAC). CABAC is a method for performing entropy coding at the best compression mode, by performing adjustment such that the frequencies of occurrence of objects to be coded that change with time coincide with the probabilities of symbols at the time of coding.
CABAC coding is mainly divided into two processes. The first is a process called binarization that converts multi-valued data to be coded which is called syntax into binary data. The second is a process of calculating a context for the binary data obtained by binarization and performing arithmetic coding.
In arithmetic coding, coding processing is performed while obtaining the probabilities of “0” and “1” for each bit of binary data. At the same time, the probabilities are updated. As described above, since arithmetic coding is a bit-by-bit process, the processing rate of arithmetic coding is generally 1 bit per clock. Also, since probabilities are adaptively switched on a bit-by-bit basis, and the probabilities for each bit are updated with the value of the bit, it is difficult to precisely know the amount of code obtained by arithmetic coding before the arithmetic coding.
In the H.264/AVC standard, if the 4:2:0 format is adopted, and the luminance and chrominance of each pixel are each represented by 8 bits, the maximum amount of code of one macroblock is 3,200 bits. If the amount of code as the result of coding one macroblock exceeds 3,200 bits, it is necessary to change coding conditions and code the macroblock again. To cope with the case where the amount of code exceeds 3,200 bits, there is also available a method for selecting I_PCM as mb_type and selecting I_PCM data instead of coded data. Since it is difficult to precisely know the amount of code obtained by CABAC until coded data is actually obtained, a judgment as to whether the maximum amount of code of a macroblock to be coded is equal to or less than a limit is made after CABAC coding.
There is also disclosed a technique for monitoring the amount of data input to an arithmetic coding unit and, if the amount of data of a certain unit of processing exceeds a threshold value, selecting one of coded data obtained by performing arithmetic coding for input data that is obtained using a parameter different from one used when the input data is obtained and uncompressed data, as data to be outputted by a picture coding device.
FIG. 1 is a block diagram showing the functional configuration of a conventional picture coding device 50.
The conventional picture coding device 50 is a device that codes input picture data and outputs a bitstream. An overview of the operation of the picture coding device 50 will be described below. The term “picture data” here refers to moving picture-related data including substantial data such as macroblock data constituting a moving picture, control information such as a macroblock type (mb_type), or other attribute information.
Data of a moving picture to be coded is inputted to a motion prediction unit 51, an intra picture prediction unit 52, and an I_PCM data buffer 53. The motion prediction unit 51 detects a block that is similar to a block to be coded among pictures other than a picture containing the block to be coded, obtains a differential image between the block to be coded and the detected block, and outputs the differential image and a motion vector to an input selection unit 54. The intra picture prediction unit 52 predicts an image of a block to be coded within a picture using an image of a block adjacent thereto, obtains a differential image between the image of the block to be coded and the predicted image, and outputs the differential image and a prediction mode to the input selection unit 54. The I_PCM data buffer 53 holds I_PCM data that is the original image data of the input moving image.
The input selection unit 54 selects one smaller in amount of data from the motion prediction unit 51 and data from the intra picture prediction unit 52. An orthogonal transformation unit 55 performs a discrete cosine transform (DCT), which is a type of orthogonal transformation, on the data selected by the input selection unit 54. A quantization unit 56 quantizes a DCT coefficient obtained by the orthogonal transformation unit 55. A binarization unit 57 binarizes a quantized DCT coefficient, a CABAC coding unit 59 performs arithmetic coding for binary data obtained by binarization, and an output buffer 60 holds the data having undergone arithmetic coding (coded data).
An I_PCM judgment unit 58 judges whether the amount of binary data outputted from the binarization unit 57 is equal to or less than a first threshold value and judges whether the amount of coded data outputted from the CABAC coding unit 59 is equal to or less than a second threshold value (e.g., 3,200 bits). If the amount of binary data is equal to or less than the first threshold value and the amount of coded data is equal to or less than the second threshold value, the I_PCM judgment unit 58 determines to select the coded data obtained by the CABAC coding unit 59 as a bitstream outputted by the picture coding device 50. On the other hand, if the amount of binary data is larger than the first threshold value or the amount of coded data is larger than the second threshold value, the I_PCM judgment unit 58 determines to select I_PCM data held by the I_PCM data buffer 53 as a bitstream outputted by the picture coding device 50. An output selection unit 61 outputs the coded data or I_PCM data to outside the picture coding device 50 in accordance with the determination made by the I_PCM judgment unit 58.
The above description is given in Patent Reference, Japanese Unexamined Patent Application Publication No. 2004-135251.
However, in the H.264/AVC standard, when motion prediction and intra picture prediction are performed for a macroblock to be processed, information of a macroblock preceding the macroblock to be processed is used. Accordingly, if a judgment as to whether the maximum amount of code of the macroblock to be processed is equal to or less than a limit is made after CABAC, as is conventionally done, it is impossible to perform motion prediction and intra picture prediction for a macroblock following the macroblock to be processed until CABAC coding of the macroblock to be processed ends. That is, a conventional picture coding device has the problem that it is incapable of processing picture data at high speed (in real time).